local jianglue = fk.CreateSkill{
    name = "ld__jianglue",
    tags = { Skill.Limited },
}

local H = require "packages.ol_hegemony.util"

jianglue:addEffect("active",{
    anim_type = "special",
    prompt = "#jianglue-active",
    can_use = function(self, player)
        return player:usedSkillTimes(jianglue.name, Player.HistoryGame) == 0
      end,
    card_filter = Util.FalseFunc,
    target_filter = Util.FalseFunc,
    on_use = function(self, room, effect)
        local player = effect.from
        local index = H.startCommand(player, jianglue.name)
        local targets = table.filter(room.alive_players, function(p) return H.compareKingdomWith(p, player) and p ~= player end)
        local tos = {} ---@type ServerPlayer[]
        if #targets > 0 then
          room:doIndicate(player, targets)
          room:sortByAction(targets)
          for _, p in ipairs(targets) do
            if player.dead then break end
            if not p.dead and H.doCommand(p, jianglue.name, index, player) then
              table.insert(tos, p)
            end
          end
        end
        table.insert(tos, 1, player)
        local num = 0
        for _, p in ipairs(tos) do
          if not p.dead then
            room:changeMaxHp(p, 1)
            if not p.dead then
              if room:recover({
                who = p,
                num = 1,
                recoverBy = player,
                skillName = jianglue.name
              }) then
                num = num + 1
              end
            end
          end
        end
        if num > 0 then player:drawCards(num, jianglue.name) end
      end
})

Fk:loadTranslationTable{
    ["ld__jianglue"] = "将略",
    [":ld__jianglue"] = "限定技，出牌阶段，你可选择一个“军令”，然后你对所有与你势力相同的角色发起此<a href='heg_Command'>“军令”</a>。你加1点体力上限，回复1点体力，所有执行“军令”的角色各加1点体力上限，回复1点体力，然后你摸X张牌（X为以此法回复体力的角色数）。",

    ["$ld__jianglue1"] = "奇谋为短，将略为要。",
    ["$ld__jianglue2"] = "为将者，需有谋略。",
}

return jianglue